package org.yierge.crm.ssm.plus.account.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yierge.crm.ssm.plus.account.pojo.param.UserLoginInfoParam;
import org.yierge.crm.ssm.plus.account.pojo.vo.UserLoginResultVO;
import org.yierge.crm.ssm.plus.account.service.UserService;
import org.yierge.crm.ssm.plus.common.web.JsonResult;

@Slf4j
@RestController(value = "account_userController")
@RequestMapping("/account")
@Validated
@Api(tags = "0.1 用户登录模块")
public class UserController {
    @Autowired
    @Qualifier(value = "account_userServiceImpl")
    private UserService userService;

    public UserController() {
        log.info("创建控制器对象：UserController");
    }

    @PostMapping("/login")
    @ApiOperation("用户登录")
    @ApiOperationSupport(order = 101)
    public JsonResult login(@Validated UserLoginInfoParam userLoginInfoParam) {
        log.debug("开始处理【用户登录】的请求，参数：{}", userLoginInfoParam);
        UserLoginResultVO userLoginResultVO = userService.login(userLoginInfoParam);
        return JsonResult.ok(userLoginResultVO);
    }

    // TODO 登出
    @PostMapping("/logout")
    @ApiOperation("用户退出登录")
    @ApiOperationSupport(order = 102)
    public JsonResult logout() {



        return JsonResult.ok();
    }
    // TODO
}
